package org.hope.nlp;

import java.util.ArrayList;
import java.util.List;

import org.hope.ontology.OntoTerm;

/**
 * @author Thilanka
 *
 */
public class SearchTerm
{
	private String word;
	private String type;
	private String pos;
	
	List<OntoTerm> ontologyTerms;
	
	private static final String OWL_CLASS = "OWLClassImpl";
	private static final String OWL_INDIVIDUAL = "OWLNamedIndividualImpl";
	
	public List<OntoTerm> _getOwlClasses()
	{
		List<OntoTerm> owlClasses = new ArrayList<OntoTerm>();
		for ( OntoTerm ontoTerm : getOntologyTerms() )
		{
			if(ontoTerm.getType().contains( OWL_CLASS ))
			{
				owlClasses.add( ontoTerm );
			}
		}
		
		return owlClasses;
	}
	
	public List<OntoTerm> _getOwlIndividuals()
	{
		List<OntoTerm> owlIndividuals = new ArrayList<OntoTerm>();
		for ( OntoTerm ontoTerm : getOntologyTerms() )
		{
			if(ontoTerm.getType().contains( OWL_INDIVIDUAL ))
			{
				owlIndividuals.add( ontoTerm );
			}
		}
		
		return owlIndividuals;
	}
	
	public String getWord()
	{
		return word;
	}
	public void setWord( String word )
	{
		this.word = word;
	}
	public String getType()
	{
		return type;
	}
	public void setType( String type )
	{
		this.type = type;
	}
	public String getPos()
	{
		return pos;
	}
	public void setPos( String pos )
	{
		this.pos = pos;
	}
	
	public List<OntoTerm> getOntologyTerms()
	{
		if(ontologyTerms == null)
		{
			ontologyTerms = new ArrayList<OntoTerm>();
		}
		return ontologyTerms;
	}
	
	public void setOntologyTerms( List<OntoTerm> ontologyTerms )
	{
		this.ontologyTerms = ontologyTerms;
	}
	
	@Override
	public String toString()
	{
		StringBuilder sb = new StringBuilder();
		sb.append( "SearchTerm [word=" + word + ", type=" + type + ", pos=" + pos );
		sb.append( " ontoterms [ \n" );
		for ( OntoTerm ontoTerm : getOntologyTerms() )
		{
			sb.append( ontoTerm + "\n" );
		}
		sb.append( "\n ]" );
		return  sb.toString();
	}	
	
}
